<?php
namespace Clover\Model;

use Think\Model;

class PromotionModel extends Model
{
    /**
     *
     * @return string
     * @author KevinBai
     */
    protected $tableName = 'dsk_promotion';

    public function get_pnum_by_dsknum($dsknum, $data)
    {

        $where = "";
        if (!empty($data['start_time'])) {
            $where .= " and fulltime > " . $data['start_time'];
        }
        if (!empty($data['end_time'])) {
            $where .= " and fulltime < " . $data['end_time'];
        }
        $sql = "SELECT * FROM dsk_promotion where promotionurl like '%$dsknum%'" . $where;


        $result = $this->query($sql);
        $pnum = count($result);
        return $pnum;
    }

    public function get_promotion_list($data)
    {
        $where = "1";
        if (!empty($data['start_time'])) {
            $where .= " and fulltime > " . $data['start_time'];
        }
        if (!empty($data['end_time'])) {
            $where .= " and fulltime < " . $data['end_time'];
        }
        $sql = "SELECT * FROM dsk_promotion where $where";
        $result = $this->query($sql);

        return $result;

    }
}

?>